package cn.northsea.listener;

import cn.northsea.mapper.LogisticsMapper;
import cn.northsea.model.logistics.Logistics;
import cn.northsea.vo.logistics.LogisiticsEeVo;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class LogisticsListener extends AnalysisEventListener<LogisiticsEeVo> {
    @Autowired
    private LogisticsMapper logisticsMapper;
    //一行一行读取
    @Override
    public void invoke(LogisiticsEeVo logisiticsEeVo, AnalysisContext analysisContext) {
        //调用方法添加数据库
        Logistics logistics = new Logistics();
        BeanUtils.copyProperties(logisiticsEeVo,logistics);
        logisticsMapper.insert(logistics);
    }
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
    }
}